﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="DeliverGoodsManagement_PrintDeliverBillWindow" Codebehind="PrintDeliverBillWindow.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>无标题页</title>
<style type="text/css">
body {text-align:center;}
.hide_for_jatools_print {} 
.tb {width:95%;}
.z1{line-height:16px;}
.z2{line-height:16px;}
.zt3 {text-align:center; font-weight:600; color:#000000;}
.zt4 {text-align:center; color:#000000;}
.bk_left {border-bottom:#A3A3A3 1px solid;border-right:#A3A3A3 1px solid;border-left:#A3A3A3 1px solid;border-top:#A3A3A3 1px solid;text-align:center; font-size:12px; font-weight:600; color:#000000;}
.bk_middle {border-bottom:#A3A3A3 1px solid;border-right:#A3A3A3 1px solid;border-left:#A3A3A3 0px solid;border-top:#A3A3A3 1px solid;text-align:center; font-size:12px; font-weight:600; color:#000000;} 
.bk_left1 {border-bottom:#A3A3A3 1px solid;border-right:#A3A3A3 1px solid;border-left:#A3A3A3 1px solid;border-top:#A3A3A3 0px solid;text-align:center; font-size:12px; color:#000000;}
.bk_middle1 {border-bottom:#A3A3A3 1px solid;border-right:#A3A3A3 1px solid;border-left:#A3A3A3 0px solid;border-top:#A3A3A3 0px solid;text-align:center; font-size:12px; color:#000000;}
.bk_middle2 {border-bottom:#A3A3A3 1px solid;border-right:#A3A3A3 1px solid;border-left:#A3A3A3 0px solid;border-top:#A3A3A3 0px solid;text-align:center; font-size:12px; color:#000000; overflow:hidden;}
</style>
    <!-- 插入打印控件 -->
    <%--<object id="jatoolsPrinter" classid="CLSID:B43D3361-D975-4BE2-87FE-057188254255"
        codebase="jatoolsPrinter_f.cab#version=2,1,0,3">
    </object>
--%>
    <script type="text/javascript">
    
    
    //初始化页面

function Init()
{   

    var url=window.location.href;
    var result = url.split('=');
    if(result.length>0)
    {
        DeliverGoodsManagement_PrintDeliverBill.GetData(result[1],Init_CallBack);  
        //doPrint();
    }
    
    
}

function Init_CallBack(response)
{
     if (response.value != null)
       {                   
        
        var ds = response.value;
        if(ds != null && typeof(ds) == "object" && ds.Tables != null)
        {    
            if(ds.Tables[0]!=null && ds.Tables[1]!=null)
            {
                for(var i=0; i<ds.Tables[0].Rows.length; i++)
                {
                    var orderId = ds.Tables[0].Rows[i].ORDER_ID;
                    var receiver = ds.Tables[0].Rows[i].ORDER_GETER;
                    var orderSource = ds.Tables[0].Rows[i].OF_NAME;
                    var totalQuantity = ds.Tables[0].Rows[i].ORDER_QTY;
                    var tranerName = ds.Tables[0].Rows[i].TRANER_NAME;
                    
                    if(i==0)
                    {
                        var temp = 0;
                        for(var j = 0;j<ds.Tables[1].Rows.length;j++)
                        {
                            if(orderId==ds.Tables[1].Rows[j].od_id && temp == 0)
                            {
                                var productId = ds.Tables[1].Rows[j].OD_CMDCODE;
                                var productName = ds.Tables[1].Rows[j].SPMC;
                                var color = ds.Tables[1].Rows[j].COLOR;
                                var size = ds.Tables[1].Rows[j].SIZE;
                                var quantity = ds.Tables[1].Rows[j].OD_QTY;
                                var note = ds.Tables[1].Rows[j].OD_NOTE;
                                if(note=="" || note==null)
                                {
                                    note = "&nbsp";
                                }
                                
                                CreateOrderTable("start",orderId,receiver,orderSource,totalQuantity,tranerName,productName,productId,color,size,quantity,note);
                                temp++;
                                continue;
                            }
                            else if(orderId==ds.Tables[1].Rows[j].od_id && temp > 0)
                            {
                                var productId = ds.Tables[1].Rows[j].OD_CMDCODE;
                                var productName = ds.Tables[1].Rows[j].SPMC;
                                var color = ds.Tables[1].Rows[j].COLOR;
                                var size = ds.Tables[1].Rows[j].SIZE;
                                var quantity = ds.Tables[1].Rows[j].OD_QTY;
                                var note = ds.Tables[1].Rows[j].OD_NOTE;
                                if(note==""|| note==null)
                                {
                                    note = "&nbsp";
                                }
                                
                                CreateOrderTable("middle","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;",productName,productId,color,size,quantity,note);
                                temp++;
                                continue;
                            }
                            else if(orderId!=ds.Tables[1].Rows[j].od_id && temp > 0)
                            {
                                CreateOrderTable("middle","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;");
                                break;
                            }
                        }
                    }
                    else
                    {
                        var temp = 0;
                        for(var j = 0;j<ds.Tables[1].Rows.length;j++)
                        {
                            if(orderId==ds.Tables[1].Rows[j].od_id && temp == 0)
                            {
                                var productId = ds.Tables[1].Rows[j].OD_CMDCODE;
                                var productName = ds.Tables[1].Rows[j].SPMC;
                                var color = ds.Tables[1].Rows[j].COLOR;
                                var size = ds.Tables[1].Rows[j].SIZE;
                                var quantity = ds.Tables[1].Rows[j].OD_QTY;
                                var note = ds.Tables[1].Rows[j].OD_NOTE;
                                if(note=="" || note==null)
                                {
                                    note = "&nbsp";
                                }
                                
                                CreateOrderTable("middle",orderId,receiver,orderSource,totalQuantity,tranerName,productName,productId,color,size,quantity,note);
                                temp++;
                                continue;
                            }
                            else if(orderId==ds.Tables[1].Rows[j].od_id && temp > 0)
                            {
                                var productId = ds.Tables[1].Rows[j].OD_CMDCODE;
                                var productName = ds.Tables[1].Rows[j].SPMC;
                                var color = ds.Tables[1].Rows[j].COLOR;
                                var size = ds.Tables[1].Rows[j].SIZE;
                                var quantity = ds.Tables[1].Rows[j].OD_QTY;
                                var note = ds.Tables[1].Rows[j].OD_NOTE;
                                if(note==""|| note==null)
                                {
                                    note = "&nbsp";
                                }
                                
                                CreateOrderTable("middle","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;",productName,productId,color,size,quantity,note);
                                temp++;
                                continue;
                            }
                            else if(orderId!=ds.Tables[1].Rows[j].od_id && temp > 0)
                            {
                                CreateOrderTable("middle","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;","&nbsp;");
                                break;
                            }
                            
                        }
                    }
                    
                    
                }
            }
          }
       }                
    return;
}
//function CreateOrderTable(orderId,customerCode,customerName,orderSource,quantity,amount,orderDate,tranerName,dealTypeName)
//    {
//        var mainDiv = document.getElementById("page1");  
//        if(mainDiv!=null)
//        {
//            
//            var tableHtml = "<h1>----------------------------------------------</h1>"; 
//            
//            tableHtml += "<table class='tb' border='0' cellspacing='0' cellpadding='0'>";
//            tableHtml += "<tr class='z1'><td class='bk_left' width=18%>订单编号</td>";
//            tableHtml += "<td class='bk_middle' width=18%>会员</td>";
//            tableHtml += "<td class='bk_middle' width=10%>订单来源</td>";
//            tableHtml += "<td class='bk_middle' width=10%>交易类型</td>";
//            tableHtml += "<td class='bk_middle' width=10%>配送方式</td>";
//            tableHtml += "<td class='bk_middle' width=8%>数量</td>";
//            tableHtml += "<td class='bk_middle' width=12%>金额</td>";
//            tableHtml += "<td class='bk_middle' width=14%>制单日期</td></tr>";
//            tableHtml += "<tr class='z2'><td class='bk_left1'>" + orderId + "</td>";
//            tableHtml += "<td class='bk_middle1'>" + customerCode + "&nbsp;&nbsp;" + customerName + "</td>";
//            tableHtml += "<td class='bk_middle1'>" + orderSource + "</td>";
//            tableHtml += "<td class='bk_middle1'>" + dealTypeName + "</td>";
//            tableHtml += "<td class='bk_middle1'>" + tranerName + "</td>";
//            tableHtml += "<td class='bk_middle1'>" + quantity + "</td>";
//            tableHtml += "<td class='bk_middle1'>" + amount + "</td>";
//            tableHtml += "<td class='bk_middle1'>" + orderDate + "</td></tr></table><br />";
//            mainDiv.innerHTML += tableHtml;
//        }      
//    }
    
function CreateOrderTable(temp,orderId,receiver,orderSource,totalQuantity,tranerName,productName,productId,color,size,quantity,note)
{
    var mainDiv = document.getElementById("page1");  
    if(mainDiv!=null)
    {
        if(temp=="start")
        {
            var tableHtml = "";
            tableHtml += "<table class='tb' border='0' cellspacing='0' cellpadding='0'>";
            tableHtml += "<tr class='z1'><td class='bk_left' width=9%>订单编号</td>";
            tableHtml += "<td class='bk_middle' width=6%>收货人</td>";
            tableHtml += "<td class='bk_middle' width=3%>总数</td>";
            tableHtml += "<td class='bk_middle' width=7%>配送方式</td>";
            tableHtml += "<td class='bk_middle' width=32%>商品名称</td>";
            tableHtml += "<td class='bk_middle' width=9%>商品代码</td>";
            tableHtml += "<td class='bk_middle' width=6%>颜色</td>";
            tableHtml += "<td class='bk_middle' width=6%>尺码</td>";
            tableHtml += "<td class='bk_middle' width=3%>数量</td></tr>";
            tableHtml += "<tr class='z2'><td class='bk_left1'>" + orderId + "</td>";
            tableHtml += "<td class='bk_middle1'>" + receiver + "</td>";
            tableHtml += "<td class='bk_middle1'>" + totalQuantity + "</td>";
            tableHtml += "<td class='bk_middle1'>" + tranerName + "</td>";
            tableHtml += "<td class='bk_middle2'>" + productName + "</td>";
            tableHtml += "<td class='bk_middle1'>" + productId + "</td>";
            tableHtml += "<td class='bk_middle1'>" + color + "</td>";
            tableHtml += "<td class='bk_middle1'>" + size + "</td>";
            tableHtml += "<td class='bk_middle1'>" + quantity + "</td></tr>";
            
            mainDiv.innerHTML += tableHtml;
        }
        else if(temp=="middle")
        {
            var tableHtml = "";
            tableHtml += "<tr class='z2'><td class='bk_left1'>" + orderId + "</td>";
            tableHtml += "<td class='bk_middle1'>" + receiver + "</td>";
            tableHtml += "<td class='bk_middle1'>" + totalQuantity + "</td>";
            tableHtml += "<td class='bk_middle1'>" + tranerName + "</td>";
            tableHtml += "<td class='bk_middle1'>" + productName + "</td>";
            tableHtml += "<td class='bk_middle1'>" + productId + "</td>";
            tableHtml += "<td class='bk_middle1'>" + color + "</td>";
            tableHtml += "<td class='bk_middle1'>" + size + "</td>";
            tableHtml += "<td class='bk_middle1'>" + quantity + "</td></tr>";
            var strHtml = mainDiv.innerHTML;
            var str = strHtml.substring(0,strHtml.length-16);
            mainDiv.innerHTML = str+tableHtml;
        }
    }
}
    
function doPrint()
{  
   
    if(typeof(jatoolsPrinter.page_div_prefix)=='undefined'){
        alert("请按页顶上的黄色提示下载ActiveX控件.如果没有提示请按以下步骤设置ie.\n 工具-> internet 选项->安全->自定义级别,设置 ‘下载未签名的 ActiveX ’为'启用'状态")
        return ;
    }
	//打印文档对象
    var myreport ={ 
                    print_settings:{
                                  // 如果想使用默认打印机,不需要设置

                                  // printer: '联想激打',

                                 // 指定纸张的高宽以毫米为单位z,本设置实际是指定为a4大小
                                pageWidth : 2100,
                                pageHeight :2970,

                               // 指定打打印方向为横向, 1/2 = 纵向/横向
                               orientation : 1 }, 
    				documents: document,    // 打印页面(div)们在本文档中
    				marginIgnored:true,
    				copyrights  :    '杰创软件拥有版权 www.jatools.com'         // 版权声明必须
    			  };
    			  
    // 调用打印方法
    //if(how == '打印预览...')
    	jatoolsPrinter.printPreview(myreport );   // 打印预览
                 
   	//else if(how == '打印...')
   		//jatoolsPrinter.print(myreport ,true);   // 打印前弹出打印设置对话框
                
   //	else
   		//jatoolsPrinter.print(myreport ,false);       // 不弹出对话框打印
   		
}
    </script>

</head>
<body onload="Init()">
    <form id="form1" runat="server">
        
        <div id="page1">
            <BR />
            <BR />
            <BR />
            <h3>配货单</h3>
            <h5>打印人：<asp:Label ID="lblOperator" runat="server"></asp:Label> &nbsp;&nbsp;  打印日期：<asp:Label ID="lblPrintDate" runat="server"></asp:Label> &nbsp;&nbsp; 配货人：________________</h5>
            
        </div>
        
    </form>
</body>
</html>
